/*
 * MIT License
 *
 * Copyright (c) 2020 wen.gu <454727014@qq.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/***************************************************************************
 * Name: avp_decoderr.h
 *
 * Purpose: implementation decoder  for av player
 *
 * Developer:
 *   wen.gu , 2022-01-19
 *
 * TODO:
 *
 ***************************************************************************/

/******************************************************************************
 **    INCLUDES
 ******************************************************************************/
#ifndef __AVP_DECODER_H__
#define __AVP_DECODER_H__

#include "avp_type.h"
#include "avp_error.h"
#include "avp_media.h"
#include "avp_frame.h"
#include "avp_packet.h"
#include "avp_codec.h"
/******************************************************************************
 **    MACROS
 ******************************************************************************/

/******************************************************************************
 **    TYPE DEFINITIONS
 ******************************************************************************/
G_C_HEADER_START


typedef struct _avp_decoder_ops
{
    GErrc (*initialize)(GPHD* handle, const avp_codec_info_t* codec_info);
    void (*finish)(GPHD handle);

    GErrc (*set_output_buffer)(GPHD handle, avp_frame_queue_t frame_queue);

    GErrc (*send_packet)(GPHD handle, avp_packet_t* pkt);
    GErrc (*receive_frame)(GPHD handle, avp_frame_t** frame);

    avp_codec_buf_provide_type_t (*output_buffer_provide_type)(GPHD handle);

}avp_decoder_ops;

typedef struct _avp_decoder
{
    GPHD handle;
    const avp_decoder_ops* ops;
}avp_decoder_t;

/******************************************************************************
 **    CLASSES/FUNCTIONS DEFINITIONS
 ******************************************************************************/

G_API GErrc avp_decoder_initialize();
G_API void avp_decoder_finish();
G_API GErrc avp_decoder_register(const avp_decoder_ops* decode_ops);
G_API GErrc avp_decoder_find(const avp_codec_info_t* codec_info, avp_decoder_t* decoder);

G_API void avp_decoder_ops_finish(const avp_decoder_t* decoder);

G_API GErrc avp_decoder_ops_set_output_buffer(const avp_decoder_t* decoder, avp_frame_queue_t frame_queue);

G_API GErrc avp_decoder_ops_send_packet(const avp_decoder_t* decoder, avp_packet_t* pkt);
G_API GErrc avp_decoder_ops_receive_frame(const avp_decoder_t* decoder, avp_frame_t** frame);

G_API avp_codec_buf_provide_type_t avp_decoder_buffer_provide_type(const avp_decoder_t* decoder);

G_C_HEADER_END

#endif /** !__AVP_DECODER_H__ */

